using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yarp.ReverseProxy.Configuration;

namespace ApiGateway
{
    public class ConsulConfigProvider : IProxyConfigProvider
    {// 集成consul客户端的依赖注入
        public IProxyConfig GetConfig()
        {
            throw new NotImplementedException("ConsulConfigProvider.GetConfig() is not implemented yet.");
            /* var services = GetFromConsul();

            var routes = services.Select(s => new RouteConfig
            {
                RouteId = s.Name,
                ClusterId = s.Name,
                Match = new RouteMatch { Path = $"/{s.Name}/{{**catch-all}}" }
            });

            var clusters = services.Select(s => new ClusterConfig
            {
                ClusterId = s.Name,
                Destinations = new Dictionary<string, DestinationConfig>
                {
                    ["d1"] = new DestinationConfig { Address = s.ServiceAddress }
                }
            });

            return new InMemoryConfig(routes, clusters); */
        }
    }

}